package com.service.admin.impl;

import com.dao.OthersDao;
import com.service.admin.AdminCommonService;
import com.utils.SqlSessionGetter;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdminCommonServiceImpl implements AdminCommonService {
  @Override
  public List<Map<String, Object>> getAllFeedBack(int pageSize, int pageIndex) {
    SqlSession session = SqlSessionGetter.getSqlSession();
    OthersDao dao = session.getMapper(OthersDao.class);
    List<Map<String, Object>> ret = dao.selectAllFeedback(pageSize * pageIndex, pageSize);
    session.close();
    return ret;
  }

  @Override
  public int setFeedBackSeen(int id) {
    SqlSession session = SqlSessionGetter.getSqlSession();
    OthersDao dao = session.getMapper(OthersDao.class);
    int row = dao.updateFeedbackStatus(id);
    session.commit();
    session.close();
    return row;
  }
}
